<template>
  <div class="box">
    <div class="allbox">
      <div class="tag_box">
        <div class="tab">{{ this.$route.meta.title }}</div>
      </div>

      <div class="table_box">
        <tabVue :list="inputlist" @onClick="sea()"></tabVue>
        <div class="table_item">
          <el-table :data="tableData" stripe fit>
            <el-table-column prop="reg_code" label="会员登记号"> </el-table-column>
            <el-table-column prop="name" label="企业名称"> </el-table-column>
            <el-table-column prop="legal_name" label="法定代表人"> </el-table-column>
            <el-table-column prop="address" label="注册地址"> </el-table-column>
            <el-table-column prop="num" label="代理人人数"> </el-table-column>
            <el-table-column label="操作" width="100">
              <template slot-scope="scope">
                <el-button @click="handleClick(scope.row)" type="text"
                  >查看</el-button
                >
              </template>
            </el-table-column>
          </el-table>
        </div>
        <div class="pagination">
          <el-pagination
            hide-on-single-page
            background
            :pager-count="5"
            layout="prev, pager, next"
            @current-change="handleCurrentChange"
            :current-page="currentPage"
            :total="total"
          >
          </el-pagination>
        </div>
      </div>
    </div>
  </div>
</template>
  
  <script>
import tabVue from "../../components/tab.vue"; //搜索框组件
export default {
  data() {
    return {
      inputlist: [
        { value: "", name: "机构名称" },
        { value: "", name: "姓名" },
      ],
      formData: {},
      tableData: [],
      total: 0,
      currentPage: 1,
    };
  },
  components: {
    tabVue: tabVue,
  },
  mounted() {
    this.getinfo();
  },
  methods: {
    /**
     * 分页
     * @param {页码} page
     */
    handleCurrentChange(page) {
      // 当分页发生变化时的处理函数
      this.currentPage = page;
      this.getinfo();
    },
    /**
     * 获取列表
     */
    getinfo() {
      let that = this;
      let data = {
        page: that.currentPage,
      };
      data = { ...data, ...that.formData };
      that.$http.post("mechanism/agent_search", data).then((res) => {
        if (res.code === 1) {
          that.total = res.data.total;
          that.tableData = res.data.data;
        } else {
          that.total = 0;
          that.tableData = [];
        }
      });
    },
    /**
     * 查询，seach()全局方法
     */
    sea() {
      let that = this;
      const vmodel = ["name", "legal_name"];
      that.formData = this.$self.seach(this.inputlist, vmodel);
      this.currentPage = 1
      that.getinfo();
      // console.log(formData);
    },
    /**
     *  查看详情
     * @param {插槽数据} e
     */
    handleClick(e) {
      // console.log(e)
      this.$router.push({ path: "/jbxq", query: { id: e.id,type:'2'  } });
    },
    //  ==
  },
};
</script>
  <style>
</style>